package io.cike.carinen;

import io.cike.carinen.config.CarinenConfig;
import io.cike.carinen.server.NamingServer;
import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
import java.io.InputStream;

public class Starter {

    public static void main(String[] args) {
        System.out.println("Hello world!");

        InputStream resource = Starter.class.getClassLoader().getResourceAsStream("config.yaml");
            Yaml yaml = new Yaml();
        CarinenConfig carinenConfig = yaml.loadAs(resource, CarinenConfig.class);

        try {
            NamingServer server = new NamingServer(carinenConfig.getServer().getPort());
            server.start();
            server.blockUntilShutdown();
        } catch (IOException | InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}